<template>
  <div class="main" >
    <el-card style="width: 60%;margin-left: 20%">
      <div slot="header" class="clearfix">
        <el-page-header title="回到问题列表" @back="back()" :content="this.$route.query.question.content" style="font-weight: bold;font-size: 28px">
        </el-page-header>
      </div>
      <el-card shadow="hover"  v-if="answerArr.length==0">
        <span style="margin-left: 45%;font-size: 16px;color: #8590A6">暂无评论哦！</span>
      </el-card>
      <div v-for="(d,index) in answerArr" :key="index">
        <el-card shadow="hover">
          <div slot="header" style="margin-top: -1%;height: 40px">
            <el-col :span="19">
              <el-avatar shape="square" :size="40"   :src="d.user.headpic"  ></el-avatar>
              <span style="font-weight: bold;font-size: 20px">{{d.user.name}}</span>
            </el-col>
            <el-col :span="4">
              <span style="font-size: 12px;margin-right: 10%">发布于: {{d.date}}</span>
            </el-col>

          </div>
          <span>{{d.content}}</span>
        </el-card>
        <el-divider ></el-divider>
      </div>

<!--      todo 回答。。。。-->
    </el-card>


  </div>
</template>

<script>
  export default {
    name: "ShowQuestion",
    components: {
    },
    props:{
      content:{
        type: String,
        default: ""
      }
    },
    data() {
      return {
          quesId:'',
        answerArr:[]
      };
    },
    created() {

    },
    mounted() {
      this.quesId=this.$route.query.question.id;
      this.getAnswer();
      // this.content=this.$route.query.article.content
    },
    methods: {
      back()
      {
        this.$router.go(-1)
      },
      getAnswer()
      {

          this.$http.get("http://localhost:8989/fornote/answer/getAnswerByQuesId?quesId="+this.quesId).then(response =>{
            this.answerArr=response.data.data;
            console.log(this.answerArr);
          })
      }
    }
  }
</script>

<style scoped>


</style>
